<?php /* Smarty version 2.6.11, created on 2011-06-22 11:26:26
         compiled from user_main.php */ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style/css/common.css" type="text/css" />
<title>管理区域</title>
<SCRIPT src="style/js/jquery-1.3.2.min.js" type=text/javascript></SCRIPT>
<SCRIPT src="style/js/main.js" type=text/javascript></SCRIPT>
<SCRIPT src="style/js/jquery-ui-1.7.2.custom.min.js" type=text/javascript></SCRIPT>
<LINK href="style/css/ui-lightness/jquery-ui-1.8.8.custom.css" type=text/css rel=stylesheet>
<script language="javascript">
$(document).ready(function(){
	$(".cbg").hover(function(){$(this).css("background-color","#F3F8F7")},function(){$(this).css("background-color","")});
});
</script>
</head>

<body>
<div id="man_zone" style="border:none;">
  <div id="tabs">
	<ul>
		<li><a href="#tabs-1">用户列表</a></li>
		<li><a href="#tabs-2">用户组列表</a></li>
	</ul>
     <div id="tabs-1" style="padding-left:0.2em;padding-right:0.4em;">
     	<table width="99%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_style"><form action="index.php?m=user&a=add" method="post">
          <tr align="">
            <td>用户名:<input name="username" type="text" class="size" />
              密码      <input name="password" type="text"  class="size" />      <input name="" type="submit" value="增加" /> <input name="" id="mkpasswd" type="button" value="生成随机密码" /> <span id="passwd"></span></td>
            </tr></form>
        </table>
        <br />
        <table width="99%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_style">
          <tr align="center">
            <td>ID</td>
            <td>用户名</td>
            <td>密码</td>
            <td>操作</td>
          </tr>
          <?php $_from = $this->_tpl_vars['users']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['val']):
?>
          <tr id="tr_<?php echo $this->_tpl_vars['val']['uid']; ?>
" align="center" class="cbg">
            <td><?php echo $this->_tpl_vars['val']['uid']; ?>
</td>
            <td><?php echo $this->_tpl_vars['val']['username']; ?>
</td>
            <td><?php echo $this->_tpl_vars['val']['password']; ?>
</td>
            <td>
                <a href="javascript:;" class="repass" uid="<?php echo $this->_tpl_vars['val']['uid']; ?>
" passwd="<?php echo $this->_tpl_vars['val']['password']; ?>
">修改密码</a> 
                <a href="index.php?m=user&amp;a=disper&uid=<?php echo $this->_tpl_vars['val']['uid']; ?>
">分配权限</a> 
                <a href="index.php?m=user&amp;a=delete&amp;uid=<?php echo $this->_tpl_vars['val']['uid']; ?>
&ajax=1" class="delete">删除</a>
            </td>
          </tr>
          <?php endforeach; endif; unset($_from); ?>
        </table>
     </div>
      <div id="tabs-2" style="padding-left:0.2em;padding-right:0.4em;">
      	<table width="99%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_style">
        <form action="index.php?m=group&a=add" method="post">
          <tr align="">
            <td>
            	组名:<input name="gname" type="text" class="size" />
              	所属站点:<select name="wid">
                <option value="">请选择站点</option>
                <?php $_from = $this->_tpl_vars['websites']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['val']):
?>
                <option value="<?php echo $this->_tpl_vars['val']['wid']; ?>
"><?php echo $this->_tpl_vars['val']['domain']; ?>
</option>
                <?php endforeach; endif; unset($_from); ?>
                </select>
                <input name="submit" type="submit" value="增加" /></td>
            </tr></form>
        </table>
        <br />
          <?php $_from = $this->_tpl_vars['websites']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['val']):
?>
          <table width="99%" border="0" align=""  cellpadding="3" cellspacing="1" class="table_style drop" domain="<?php echo $this->_tpl_vars['val']['domain']; ?>
" wid="<?php echo $this->_tpl_vars['val']['wid']; ?>
">
              <tr align="" style="background-color:#F3F8F7;">
                <td style="padding-left:30px;"><?php echo $this->_tpl_vars['val']['domain']; ?>
</td>
              </tr>
          </table>
          <?php $this->assign('wid', $this->_tpl_vars['val']['wid']); ?>
          <?php if ($this->_tpl_vars['wid']): ?>
          <?php $_from = $this->_tpl_vars['groups'][$this->_tpl_vars['wid']]; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['value']):
?>
          <table width="99%" border="0" align=""  cellpadding="3" cellspacing="1" class="table_style drag"  style="cursor:move" gid="<?php echo $this->_tpl_vars['value']['gid']; ?>
" gname="<?php echo $this->_tpl_vars['value']['gname']; ?>
" >
              <tr align="" style="">
                <td style="padding-left:60px;">|-- <a href="index.php?m=group&a=edit&gid=<?php echo $this->_tpl_vars['value']['gid']; ?>
"><?php echo $this->_tpl_vars['value']['gname']; ?>
</a> <a href="index.php?m=group&a=delete&gid=<?php echo $this->_tpl_vars['value']['gid']; ?>
" class="delete"><img src="style/images/delete.png" width="10" height="10" border="0" /></a></td>
              </tr>
          </table>
          <?php endforeach; endif; unset($_from); ?>
          <?php endif; ?>
          <?php endforeach; endif; unset($_from); ?>
        
     </div>
 </div>

</div>

<div id="repassBox" style="display:none;">
<input name="password" type="text" id="password" value="12" class="size" />
<input type="hidden" name="uid" value="" id="uid" />
</div>

<script language="javascript">
$("#mkpasswd").click(function(){
	$("#passwd").load("index.php?m=user&a=mkpasswd");
});
$( ".drag" ).draggable({ 
	revert: "invalid", 
	axis: "y",
	containment: "#containment-wrapper", 
	scroll: false,helper: "clone" ,
	start:function(){
		gid = $(this).attr("gid");
		gname = $(this).attr("gname");
	}
});
$( ".drop" ).droppable({
	activeClass: "ui-state-hover",
	hoverClass: "ui-state-active",
	drop: function( event, ui ) {
		var domain = $(this).attr("domain");
		var wid = $(this).attr("wid");
		var warn = "确定要把用户组 "+gname+" 复制到 "+domain+" 吗?";
	    if(confirm(warn)){
			window.location = "index.php?m=user&a=copy&gid="+gid+"&wid="+wid;
		} else return false;
	}
});
$(".repass").click(function(){
	var passwd = $(this).attr("passwd");
	var uid = $(this).attr("uid");
	$("#password").val(passwd);
	$("#uid").val(uid);
	$("#repassBox").dialog({
		show: "",
		hide: "",
		title:'请输入新密码',
		buttons: {
			"确定": function() {
				var passwd = $("#password").val(passwd);
				var uid = $("#uid").val();
				$.post("index.php?m=user&a=repass&ajax=1",{"password":passwd,"uid":uid},function(data){
					if (data == '1'){
						overBox('<span style="color:green;">修改成功</span>');
						setTimeout(function(){window.location.reload();}, 1000);
					}else {
						overBox('<span style="color:red;">修改失败,请联系管理员</span>');
					}
				});
				BoxRemove("#repassBox");
			},
			"关闭": function() {
				BoxRemove("#repassBox");
			}
		}
	});
});
</script>
</body>
</html>